import request from '@/request/request'

export const equipmentApi = {
  // ==================== 设备档案管理 ====================

  // 分页查询设备列表
  getDevicePage: (data) => {
    return request({
      url: '/device/page',
      method: 'post',
      data
    })
  },

  // 根据ID获取设备详情
  getDeviceById: (id) => {
    return request({
      url: `/device/${id}`,
      method: 'get'
    })
  },

  // 新增设备
  addDevice: (data) => {
    return request({
      url: '/device',
      method: 'post',
      data
    })
  },

  // 更新设备
  updateDevice: (id, data) => {
    return request({
      url: `/device/${id}`,
      method: 'put',
      data
    })
  },

  // 删除设备
  deleteDevice: (id) => {
    return request({
      url: `/device/${id}`,
      method: 'delete'
    })
  },

  // 获取设备状态列表
  getDeviceStatusList: () => {
    return request({
      url: '/device/status/list',
      method: 'get'
    })
  },

  // 获取设备类型列表
  getDeviceTypeList: () => {
    return request({
      url: '/device/type/list',
      method: 'get'
    })
  },

  // ==================== 设备维护管理 ====================

  // 分页查询设备维护列表
  getDeviceMaintenancePage: (data) => {
    return request({
      url: '/device/maintenance/page',
      method: 'post',
      data
    })
  },

  // 根据ID获取设备维护详情
  getDeviceMaintenanceById: (id) => {
    return request({
      url: `/device/maintenance/${id}`,
      method: 'get'
    })
  },

  // 新增设备维护
  addDeviceMaintenance: (data) => {
    return request({
      url: '/device/maintenance',
      method: 'post',
      data
    })
  },

  // 更新设备维护
  updateDeviceMaintenance: (id, data) => {
    return request({
      url: `/device/maintenance/${id}`,
      method: 'put',
      data
    })
  },

  // 删除设备维护
  deleteDeviceMaintenance: (id) => {
    return request({
      url: `/device/maintenance/${id}`,
      method: 'delete'
    })
  },

  // 开始维护
  startMaintenance: (id) => {
    return request({
      url: `/device/maintenance/${id}/start`,
      method: 'post'
    })
  },

  // 完成维护
  completeMaintenance: (id, data) => {
    return request({
      url: `/device/maintenance/${id}/complete`,
      method: 'post',
      data
    })
  },

  // ==================== 设备运行管理 ====================

  // 分页查询设备运行记录
  getDeviceOperationPage: (data) => {
    return request({
      url: '/device/operation/page',
      method: 'post',
      data
    })
  },

  // 根据ID获取设备运行记录详情
  getDeviceOperationById: (id) => {
    return request({
      url: `/device/operation/${id}`,
      method: 'get'
    })
  },

  // 新增设备运行记录
  addDeviceOperation: (data) => {
    return request({
      url: '/device/operation',
      method: 'post',
      data
    })
  },

  // 更新设备运行记录
  updateDeviceOperation: (id, data) => {
    return request({
      url: `/device/operation/${id}`,
      method: 'put',
      data
    })
  },

  // 删除设备运行记录
  deleteDeviceOperation: (id) => {
    return request({
      url: `/device/operation/${id}`,
      method: 'delete'
    })
  },

  // 结束运行
  endOperation: (id, data) => {
    return request({
      url: `/device/operation/${id}/end`,
      method: 'post',
      data
    })
  }
}
